import { ref } from 'vue'
import { defineStore } from 'pinia'
import { sendRequest } from '@/utils/api'
import type { HttpResponse } from '@/utils/http'

export const userCenterStore = defineStore('userCenter', () => {
  const messageCount = ref(0)
  const examineCount = ref(0)
  const receiveCount = ref(0)

  const getTopCount = async () => {
    const [error, res] = await sendRequest<HttpResponse>({
      module: 'userCenter',
      api: 'topCount'
    })
    if (error) return
    messageCount.value = res.data.noticeCount
    examineCount.value = res.data.waitSubmitCount
    receiveCount.value = res.data.detailsCount
  }

  return {
    getTopCount,
    messageCount,
    examineCount,
    receiveCount
  }
})
